//MINI UI解析
mini.parse();

//名称处理器类
function EditNameHandler() {
	this.data = {};
	this.form = new mini.Form("editNameForm");
	
	this.load = function(data) {
		data = mini.clone(data);
		this.data.forres = data.forres;
		this.data.iscreate = data.iscreate;
		this.data.orgin = data.name;
		this.data.parent = data.parent;
		
		this.form.setData(data);
	};
	
	this.confirm = function() {
		this.form.validate();
		if (this.form.isValid()) {
			var data = this.form.getData();
			data.forres = this.data.forres;
			data.iscreate = this.data.iscreate;
			data.orgin = this.data.orgin;
			data.parent = this.data.parent;
			
			var json = mini.encode(data);
			$.ajax({
				url : __root + "/editName.do", 
				type : "POST", 
				data: {
		        	data: json,
		        	lslUser: gbOperateUser,
		    		lslAddress: gbOperateIp
		        },
				dataType : "json", 
				success : function(result) {
					if (result.issuccess) {
						instance.close("confirm");
					} else {
						mini.alert(result.message, "系统提示");
					}
				}, 
				error : function (request) {
					mini.alert(request.responseText, "系统提示");
				}
			});
		}
	};
	
	this.close = function(action) {
		if (CloseOwnerWindow) {
			CloseOwnerWindow(action);
		} else {
			window.close();
		}
	};
};

//名称处理器全局实例
var instance = new EditNameHandler();

//定义确定按钮点击事件处理程序
function onConfirmClick(e) {
	instance.confirm();
}

//定义关闭按钮点击事件处理程序
function onCancelClick(e) {
	instance.close("cancel");
}
